<script type="text/javascript">

$(document).ready(function(){

$("#value_brokerage").change(function(){
var value=$(this).val();

var premiAwal = parseInt($("#biaya_kartu").val());
var diskonAgra = parseInt($("#discount").val());
var diskonAsuransi = parseInt($("#diskon_asuransi").val());

//if(client_tahu_diskon=="1"){
//	var diskon = 0;
//}
//else{
	//var diskon = diskonAgra+diskonAsuransi;
	var diskon = diskonAsuransi;
//}


if(value=="1"){
	$("#hasil-premi").text(premiAwal);
	$("#txt_hasil_premi").val(premiAwal);
}
else{
	$("#hasil-premi").text(premiAwal-diskon);
	$("#txt_hasil_premi").val(premiAwal-diskon);	
}

});



});

</script>

<div class="form">

    <?php $form=$this->beginWidget('bootstrap.widgets.TbActiveForm', array(
	'id'=>'ndk-health-form',
	// Please note: When you enable ajax validation, make sure the corresponding
	// controller action is handling ajax validation correctly.
	// There is a call to performAjaxValidation() commented in generated controller code.
	// See class documentation of CActiveForm for details on this.
	'enableAjaxValidation'=>false,
)); ?>

    <p class="help-block">Fields with <span class="required">*</span> are required.</p>

    <?php echo $form->errorSummary($model); ?>
		<div class="row">
		<div class="col-md-4">
			<div class="widget box">
				<div class="widget-header">
					<h4><i class="icon-reorder"></i> Form Ganti Kartu </h4>
				</div>
				<div class="widget-content">
			
			
				
            <?php echo $form->textFieldControlGroup($modelKartu,'nota_no',array('class'=>'form-control','maxlength'=>50,'readOnly'=>true,'value'=>'Automatic Fill')); ?>

			<div class="control-group">
				<label class="control-label">
				Policy No
				<span class="required">*</span>
				</label>
				<div class="controls">
					<div class="input-group">
						<input id="policy_no" class="form-control input-width-large" type="text" name="policy_no">
						<a class="btn btn-default btn-warning" href="#myModal" data-toggle="modal" style="float:right">FIND</a>
					</div>
					<input type="hidden" name="GantiKartu[reg_policy_id]" id="reg_policy_id" />
					<input type="hidden" name="GantiKartu[type_reg_policy]" id="type_reg_policy" />
				</div>
			</div>
            <?php echo $form->textFieldControlGroup($modelKartu,'endorsement_no',array('class'=>'form-control','maxlength'=>50)); ?>

            <?php echo $form->textFieldControlGroup($modelKartu,'biaya_kartu',array('class'=>'form-control','maxlength'=>50,'id'=>'biaya_kartu')); ?>


				</div>
			</div>
		</div>
		
		<div class="col-md-4">
			<div class="widget box">
				<div class="widget-header">
					<h4><i class="icon-reorder"></i> Form Ganti Kartu </h4>
				</div>
				<div class="widget-content">
			
							
            		<?php echo $form->textFieldControlGroup($modelKartu,'admin_broker',array('class'=>'form-control')); ?>

					<?php echo $form->textFieldControlGroup($modelKartu,'stamp_duty',array('class'=>'form-control')); ?>

					<?php echo $form->textFieldControlGroup($modelKartu,'stampduty_asuransi',array('class'=>'form-control')); ?>

					

					<div class="control-group">
					<label class="control-label" for="NdkHealthNon_ppn">Diskon Internal / Agra</label>
										<div class="controls">
											<div class="input-group">
												<?php echo $form->textField($modelKartu,'discount',array('class'=>'form-control input-width-large','id'=>'discount')); ?>
											</div>
										</div>
					</div>

					<div class="control-group">
					<label class="control-label" for="NdkHealthNon_ppn">Diskon Asuransi</label>
										<div class="controls">
											<div class="input-group">
												<?php echo $form->textField($modelKartu,'diskon_asuransi',array('class'=>'form-control input-width-large','id'=>'diskon_asuransi')); ?>
											</div>
										</div>
					</div>



				
	</div>
			</div>
		</div>
		
		<div class="col-md-4">
			<div class="widget box">
				<div class="widget-header">
					<h4><i class="icon-reorder"></i> Form Ganti Kartu </h4>
				</div>
				<div class="widget-content">
			
			<div class="control-group">
			<label class="control-label">
			Due Date
			<span class="required">*</span>
			</label>
			<div class="controls">
			<div class="input-group">
			<?php echo $form->textField($modelKartu,'due_date', array('class'=>'form-control input-width-large','data-mask'=>"99-99-9999")); ?>
			</div>
			</div>
			</div>
			
            <br />
					<?php echo $form->dropDownList($modelKartu, 'value_brokerage', array(1 => "Biaya Kartu Awal", 2 => "Biaya Kartu - Diskon"),array('prompt'=>'Pilih','id'=>'value_brokerage','class'=>'form-control input-width-medium')); ?>
												<br />
												<strong>Premi : <span id="hasil-premi"></span></strong>													
												<input type="hidden" name="txt_hasil_premi" id="txt_hasil_premi" />
												<br />


            <?php echo $form->textAreaControlGroup($modelKartu,'note',array('class'=>'form-control','maxlength'=>100)); ?>
		


      
	
	</div>
			</div>
		</div>
		
	</div>
	
	
	
	<div class="row">
		
		<div class="col-md-12">
		  <div class="form-actions">
        <?php echo TbHtml::submitButton($model->isNewRecord ? 'Create' : 'Save',array(
		    'color'=>TbHtml::BUTTON_COLOR_PRIMARY,
		    'size'=>TbHtml::BUTTON_SIZE_LARGE,
		)); ?>
		</div>
		</div>
	</div>
	
	<div id="myModal" class="modal fade in" style="display: none;" aria-hidden="false">
												<div class="modal-dialog" style="width:700px;">
													<div class="modal-content">
														<div class="modal-header">
															<button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button>
															<h4 class="modal-title">Pilih Client</h4>
														</div>
														<div class="modal-body">
															
															<?php echo $this->renderPartial('_viewClient', array('model'=>$model2));  // I need $productId to by dynamic related to link 
                ?> 
														</div>
														<div class="modal-footer">
															<button data-dismiss="modal" class="btn btn-default" type="button">Close</button>
															<button id="btnTest" data-dismiss="modal" class="btn btn-primary" type="button">Pilih</button>
														</div>
													</div><!-- /.modal-content -->
												</div><!-- /.modal-dialog -->
	</div>



	
    <?php $this->endWidget(); ?>

</div><!-- form -->

<script type="text/javascript">
$(document).ready(function(){


$("#btnTest").click(function()
{
	var nil = "";
    nil = $('input:radio[name=user]:checked').val()+" - "+$('input:radio[name=user]:checked').attr('nama_client');
   $("#policy_no").val(nil);
   $("#reg_policy_id").val($('input:radio[name=user]:checked').attr('id_number'));
   $("#type_reg_policy").val($('input:radio[name=user]:checked').attr('typereg'));
}); 


}); 

</script>

